////////////////////////////////////////////////////////////////////////
// Last svn revision: $Id:  $ 
////////////////////////////////////////////////////////////////////////

#include "MLCTest/TMatrixOp.hh"

using namespace drow;
using namespace MLC;

namespace drow {
namespace test {

void TMatrixOp::TestClass() {
  TestAdd();
}

Matrix TMatrixOp::CreateNewMatrix(double* data, int rows, int cols) {
  Matrix returnVar;
  returnVar.Data = data;
  returnVar.Rows = rows;
  returnVar.Columns = cols;
  return returnVar;
}

void TMatrixOp::TestAdd() {
    //initial set up
    Matrix A, B;
    A = CreateNewMatrix(0, 3, 1);
    B = CreateNewMatrix(0, 3, 1);
    A.Data = new double[3];
    B.Data = new double[3];
    A.Data[0] = 1; A.Data[1] = 2; A.Data[2] = 3;
    B.Data[0] = 1; B.Data[1] = 5; B.Data[2] = 3;
    Matrix C = A + B;
    
    //tests that all addition occured properly
    AssertTrue(C.Data[0] == 2, 45);
    AssertTrue(C.Data[1] == 7, 46);
    AssertTrue(C.Data[2] == 6, 47);
    
    //tests that matrix 
    B.Rows = 5;
    AssertFailure([A,B]() { A + B; }, 43);
}

}
}